<template>
  <div class="Read">
    <Banner :ImgObj="ImgObj"></Banner>
    <div class="Readtitle">
      <div class="content">
        <div class="left">
          <!--<img src="../../../../assets/logo.png" alt="">-->
          <img :src="user_info.avatar" alt="">
          <span>{{user_info.nickname}}</span>
        </div>
        <div class="right">
          <span>已阅读{{user_info.read_days}}天 | 未阅读{{user_info.absence_read_days}}天</span>
        </div>
      </div>
    </div>
    <div class="Readnav">
      <p v-if="is_vip===1">会员截止:{{user_info.reading_vip_period_validity}}</p>
    </div>
    <Reading :daylist="daylist" :now="now" v-if="isobj" v-on:initData="Dateup" v-on:Patch="Patch"
             ref="Reading"></Reading>
    <!--<schedule :Schedule="schedule"></schedule>-->
  </div>
</template>

<script>
  import Banner from '../../../../components/Banner/index'
  import Reading from '../../../../components/Reading/index'
  import Schedule from '../../../../components/schedule/index'

  export default {
    name: 'index',
    data: function () {
      return {
        daylist: [],
        ImgObj: [
          {adver_cover: require('../../../../assets/img/Home/Read/WechatIMG4.png'), adver_link: ''}
        ],
        user_info: {
          avatar: require('../../../../assets/img/BookShelf/zhang1.png'),
          nickname: '',
          read_level: 0,
          read_words: 0,
          read_days: 0,
          absence_read_days: 0
        },
        daysall: {year: -1, month: -1},
        is_vip: 0,
        schedule: {},
        isobj: false,
        now: '1997-01-01'
      }
    },
    mounted: function () {
      this.Upimg()
      this.Dateup(this.daysall)
      var logger = this.$axios.logger()
      logger.push('user_id', this.$Login.oauth_token.user_id)
      logger.push('page_url', window.location.href);
      logger.push('user_action', 10);
      logger.push('platform_id', 5);
      logger.push('platform_user_id', this.$Login.Vip_token.vip_user_id);
      logger.push('share_id', this.$route.query.share_id || -1);
      logger.push('share_token', this.$route.query.share_token || '-1');
      logger.logger();
    },
    methods: {
      Upimg: function () {
        this.$axios.adver_list({
          adver_type: 4
        }).then(res => {
          this.ImgObj = res.data.qing_data.adver_info
          this.user_info = res.data.qing_data.user_info
        })
      },
      Dateup: function (data) {
        this.isobj = true
        this.$axios.schedule(data).then(res => {
          if (res.data.qing_code !== 100) {
            return
          }
          this.daylist = res.data.qing_data.calender
          this.now = res.data.qing_data.now
          this.Patchs(res.data.qing_data.make_up_desc)
          this.is_vip = res.data.qing_data.is_vip
          // var isreads = localStorage.getItem('tenisreads')
          // if (!isreads && this.is_vip === 1 && !isreads !== 1) {
          //   this.$emit('showpopup')
          // }
          if (data.year !== -1) {
            // this.isobj = true
            var str = {
              FullYear: data.year,
              Month: data.month - 1
            }
            this.daysall = {
              year: data.year,
              month: data.month
            }
            // this.isobj = true
            this.$refs.Reading.List(this.daylist)
            this.$refs.Reading.initData(str)
          } else {
            this.$refs.Reading.List(this.daylist)
            this.$refs.Reading.initData()
          }
          // this.isobj = false
          // var _this = this
          // setTimeout(() => {
          this.isobj = true
          // }, 500)
        })
      },
      Patch: function (obj) {
        this.$emit('show', obj)
      },
      Patchs: function (str) {
        this.$emit('showtext', str)
      }
    },
    components: {Banner, Reading, Schedule}
  }
</script>

<style scoped>
  @import "../../../../assets/css/components/Home/Read/index.css";

</style>
